{include file="public/_meta" /}
{include file="public/_nav" /}

<div class="container body">
    <div class="col-xs-2">
        {include file="public/_left" /}
    </div>
    <div class="col-xs-10">
        <ol class="breadcrumb">
            导航位置：<li><a href="#">栏目列表</a></li>
        </ol>
        <h2>栏目列表<small>{if $cateInfo->total()}共计{$cateInfo->total()}条{else /}无数据{/if}</small></h2>
        <table class="table table-hover table-responsive table-striped table-bordered">
            <thead>
            <tr>
                <th>ID</th>
                <th>栏目名称</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="cateInfo" id="vo"}
            <tr>
                <td>{$vo.id}</td>
                <td>{$vo.catename}</td>
                <td>
                    <a href="{:url('admin/home/cateedit', ['id' => $vo.id])}" class="btn btn-primary btn-xs">编辑</a>
                    <button class="btn btn-danger btn-xs catedel" _id="{$vo.id}">删除</button>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <nav class="text-center">
            {$cateInfo->render()|raw}
        </nav>
    </div>
</div>

{include file="public/_js" /}
<script>
    $('.catedel').click(function () {
        $.ajax({
            url:"{:url('admin/home/catedel')}",
            type:'post',
            data:{id:$(this).attr('_id')},
            dataType:'json',
            success:function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {
                        icon:6,
                        time:2000
                    },function () {
                        location.href = data.url;
                    });
                }else {
                    layer.open({
                        title:'导航删除失败',
                        content:data.msg,
                        icon:5,
                        anim:6,
                        skin:'layui-layer-lan'
                    });
                }
            }
        });
        return false;
    });
</script>
</body>
</html>